﻿using FluentNHibernate.Mapping;

namespace Application_Core.Kunde_Component.Data_Access_Layer
{
    public class KundeMap : ClassMap<Kunde>
    {
        public KundeMap()
        {
            Id(x => x.Id)
                .GeneratedBy.Identity()
                .Length(11);
            Map(x => x.Nummer)
                .Not.Nullable()
                .Length(11)
                .Unique();
            Map(x => x.Vorname)
                .Nullable()
                .Length(150);
            Map(x => x.Nachname)
                .Not.Nullable()
                .Length(150);
            Component(x => x.Adresse, m =>
                {
                    m.Map(c => c.Strasse)
                        .Nullable()
                        .Length(150);
                    m.Map(c => c.Hausnummer)
                        .Nullable()
                        .Length(11);
                    m.Map(c => c.PLZ)
                        .Nullable()
                        .Length(5);
                    m.Map(c => c.Ort)
                        .Nullable()
                        .Length(150);
                });
        }
    }
}
